package com.kly.user.utils;

import com.fqgj.common.utils.StringUtils;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class ServiceUtils {

    public static Map<String, Object> getParams() {
        Map<String, Object> params = new HashMap<>();
        params.put("deleted", 0);
        return params;
    }

    public static Date getDateTime(double lat, double lng) {
//        Map<String, Object> params = ServiceUtils.getParams();
//        params.put("userCode", userCode);
//        List<UserBehaviorGpsEntity> gpsEntities = userBehaviorGps.selectByParams(params);
//        if (CollUtil.isNotEmpty(gpsEntities)) {
//
//        } else {
//
//        }
        String timeZoneId = "UTC-5";
        // 根据时区ID创建ZoneId
        ZoneId zoneId = ZoneId.of(timeZoneId);
        // 使用ZonedDateTime获取当前时区的时间
        ZonedDateTime zonedDateTime = ZonedDateTime.now(zoneId);
        // 将 ZonedDateTime 对象转换为 java.util.Date 对象
        return Date.from(zonedDateTime.toInstant());
    }

    public static String getImageUrl(String url, String photoPrefix) {
        String imageUrl;
        if (!StringUtils.isEmpty(url) && !url.contains(photoPrefix)) {
            imageUrl = photoPrefix + url;
        } else {
            imageUrl = url;
        }
        return imageUrl;
    }

    public static boolean notNullOrZero(Integer num) {
        return !(num == null || num == 0);
    }

    public static Integer feetInchesToCentimeters(String feetInches) {
        if (feetInches == null
                || (!feetInches.matches("\\d+'\\d+\"")
                && !feetInches.matches("\\d+'\\d+\"\""))) {
            return null;
        }

        String[] parts = feetInches.split("'");
        int feet = Integer.parseInt(parts[0].trim());
        int inches = Integer.parseInt(parts[1].replace("\"", "").trim());

        return (int) ((feet * 30.48) + (inches * 2.54));
    }

}
